import random

ip = "172.25.254."
with open("ips.txt", "w+") as f:
    for i in range(120000):
        rd = random.randint(1, 256)
        f.write(f"{ip}{rd}\n")

with open("ips.txt", "r") as f:
    ip_dict = {}
    for i in f:
        if i not in ip_dict:
            ip_dict[i] = 0
        ip_dict[i] = ip_dict.get(i) + 1
t = []
for i, j in ip_dict.items():
    t.append(j)

t.sort(reverse=1)
t2 = t[0:10]

for i, m in enumerate(t2):
    for k, j in ip_dict.items():
        if j == m:
            print(f"第{i + 1}名是:{k}出现次数为{j}")
